home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 177 / c / printc.doc < prev    next >
Encoding:
Text File  |  1987-09-15  |  2.0 KB  |  75 lines

  1. **********
  2. Topic 31        Thu Mar 26, 1987
  3. M.OMASSEY                    at 18:30 PST
  4. Sub: output to printer info needed in c     
  5.  
  6. I'm new to c, just afew months, I have Megamax and don't understand how to
  7. send output to printer. like the Lprint in basic statment. Please help..I have
  8. looked at many books. no one seems to cover it.
  9. 4 message(s) total
  10. **********
  11. ----------
  12. Category 3,  Topic 31
  13. Message 1         Mon Mar 30, 1987
  14. TEDMILLER                    at 02:20 EST
  15.           
  16. You will have to write a procedure to do it yourself using BIOS calls or
  17. GEMDOS calls. try this (I have never had to do this, so I am not sure if it
  18. will work!)
  19.  
  20. print(string,length) char *string;  int length; { int i; for (i=0 ; i<length ;
  21. i++)
  22.    {
  23.    do {} while (Cprnos==0);
  24.    Cprnout((char)(string[i]));
  25.    } } This might print a string of length length. Good luck.
  26. ----------
  27. Category 3,  Topic 31
  28. Message 2         Thu Apr 02, 1987
  29. JWEAVERJR [FactProg]         at 15:47 EST
  30.           
  31. easier way:
  32.  
  33. print(string, length)
  34.  *string; int length; {
  35.     while (length--)
  36.     {
  37.         Cprnout(*string++);
  38.     } }
  39.  
  40.   -JWJr
  41. ----------
  42. Category 3,  Topic 31
  43. Message 3         Fri Apr 03, 1987
  44. TIMPURVES [Turbo_tim]        at 23:41 EST
  45.           
  46. or even easier print(string) char *string; {
  47.     while(*string)
  48.       printc(*string++); }
  49.  
  50. printc(ch) int ch; {
  51.  if(ch == '\n')
  52.    printc('\r'); /* convert \n to \r\n on the fly! */
  53.  bios(3,0,ch);  /* bios bconout to printer */ }
  54.  
  55. /* use printc() for a character
  56.    use print()  for a string
  57.  */
  58. ----------
  59. Category 3,  Topic 31
  60. Message 4         Thu May 21, 1987
  61. E.C0LLINS                    at 19:08 PDT
  62.           
  63. To use the printer from LATTICE C, all you have to do is open a file and  use
  64. fprintf or fputs instead of printf or puts. For example:
  65.  
  66. print(string)
  67.    {
  68.    FILE *fopen,*fp;
  69.  
  70.    fp = fopen("LST:","w");  /* open the printer for writing */]
  71.    fputs(string,fp);
  72.    fclose(fp);
  73.    }
  74. ----------
  75.